<template>
  <el-dialog v-model="visible" :close-on-click-modal="false" width="821" custom-class="login-dialog" @open="handleOpen">
    <div class="login-dialog-content">
      <!-- 左侧扫码登录区域 -->
      <div class="scan-login-section">
        <div class="sub-scan-login-section">
          <div id="wechat_qrlogin"></div>
          <div class="scan-qr-code">
            <img class="qr-code-img" src="@/assets/images/login/login-qrcode.png" alt="">
          </div>
          <div class="scan-login-text">
            <img class="text-img" src="../assets/images/login/wx-logo.png" alt="">
            微信扫码登录
          </div>
        </div>
      </div>

      <!-- 右侧账号登录区域 -->
      <div class="account-login-section">
        <div class="sub-account-login-section">
          <div class="login-tabs">
            <!-- 简化登录方式 -->
            <div class="login-tabs-title">{{ isNext ? '新密码' : '验证手机号' }}</div>
          </div>

          <!-- 验证码登录表单 -->
          <el-form ref="smsFormRef" :model="smsForm" :rules="smsRules" class="login-form">
            <div v-if="!isNext">
              <el-form-item prop="phone" :validate-event="false">
                <el-input v-model="smsForm.phone" placeholder="请输入手机号" @input="handlePhoneInput($event, 'sms')"
                  clearable></el-input>
              </el-form-item>
              <el-form-item prop="smsCode" :validate-event="false">
                <el-input v-model="smsForm.smsCode" placeholder="请输入验证码" class="sms-code-input" clearable>
                  <template #append>
                    <el-button type="text" :disabled="smsButtonDisabled" @click="handleGetSmsCode"
                      class="get-sms-button">
                      {{ smsButtonText }}
                    </el-button>
                  </template>
                </el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" :class="smsLoginButtonClass" @click="handleSmsLogin" :loading="loading">
                  下一步
                </el-button>
              </el-form-item>
              <el-link type="primary" class="forgot-password" :underline="false" @click="backLogin">
                <img src="@/assets/images/login/left-arrow.png" alt="">
              </el-link>
            </div>
            <div v-else>
              <el-form-item prop="password" :validate-event="false">
                <el-input v-model="passwordForm.password" :type="showPassword ? 'text' : 'password'"
                  placeholder="请输入新密码">
                  <template #suffix>
                    <div class="password-toggle-icon" @click="togglePasswordVisibility">
                      <View v-if="showPassword" />
                      <Hide v-else />
                    </div>
                  </template>
                </el-input>
              </el-form-item>

              <el-form-item prop="confirmPassword" :validate-event="false">
                <el-input v-model="passwordForm.confirmPassword" :type="confirmShowPassword ? 'text' : 'password'"
                  placeholder="请再次输入密码">
                  <template #suffix>
                    <div class="password-toggle-icon" @click="toggleConfirmPasswordVisibility">
                      <View v-if="confirmShowPassword" />
                      <Hide v-else />
                    </div>
                  </template>
                </el-input>
              </el-form-item>
              <el-form-item>
                <p class="password-tip">
                  密码长度需在8-16位之间，且必须同时包含字母和数字
                </p>
                <el-button type="primary"
                  :class="['login-submit-button', 'login-submit-button-active', { 'disabled': !passwordFormValid }]"
                  @click="confirmModify" :loading="loading">
                  确定
                </el-button>
              </el-form-item>
              <el-form-item>
                <el-link type="primary" class="forgot-password" :underline="false" @click="goBackToVerify">
                  <img src="@/assets/images/login/left-arrow.png" alt="返回">
                </el-link>
              </el-form-item>
            </div>
          </el-form>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script setup>
import { ref, onMounted, reactive, computed, watch } from 'vue'
import { Hide, View } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import errorIcon from '@/assets/images/error-icon.png'
import successIcon from '@/assets/images/success-icon.png'
import { useUserStore } from '../stores/user'
import { useRouter } from 'vue-router'
import { domesticUserCenter } from 'ld-web-sdk';
// import CryptoJS from 'crypto-js';

// 定义组件名称
defineOptions({
  name: 'VerifyPhone'
})

// 定义事件
const emit = defineEmits(['loginSuccess', 'backLogin'])

// 状态管理
const userStore = useUserStore()
const router = useRouter()

// 弹窗显示状态
const visible = ref(false)

// 表单引用
const smsFormRef = ref(null)
const passwordFormRef = ref(null)

// 加载状态
const loading = ref(false)

// 密码可见性
const showPassword = ref(false)
const confirmShowPassword = ref(false)

// 切换密码可见性
const togglePasswordVisibility = (event) => {
  showPassword.value = !showPassword.value
  // 阻止事件冒泡，避免触发输入框的失焦事件
  event.stopPropagation()
}

// 切换确认密码可见性
const toggleConfirmPasswordVisibility = (event) => {
  confirmShowPassword.value = !confirmShowPassword.value
  // 阻止事件冒泡，避免触发输入框的失焦事件
  event.stopPropagation()
}



// 协议同意
const agreementChecked = ref(false)
const isNext = ref(false)

// 验证码按钮状态
const smsButtonDisabled = ref(false)
const smsButtonText = ref('获取验证码')
let smsCountdown = null

// 表单验证状态
const smsFormValid = ref(false)

// 验证码登录表单数据
const smsForm = reactive({
  phone: '',
  smsCode: ''
})

// 密码登录表单数据
const passwordForm = reactive({
  phone: '',
  password: '',
  confirmPassword: '',
  rememberMe: false,
  autoLogin: false
})

// 密码验证辅助函数
const checkPasswordValidity = (password) => {
  const hasLetter = /[a-zA-Z]/.test(password)
  const hasNumber = /\d/.test(password)
  const isValidLength = password.length >= 8 && password.length <= 16
  return hasLetter && hasNumber && isValidLength
}

// 表单验证状态 - 使用computed属性自动计算密码表单的有效性
const passwordFormValid = computed(() => {
  return passwordForm.password &&
    passwordForm.confirmPassword &&
    passwordForm.password === passwordForm.confirmPassword &&
    checkPasswordValidity(passwordForm.password)
})


// 提取正则表达式为常量
const REGEX_PHONE = /^1[3-9]\d{9}$/
const REGEX_USERNAME = /^[a-zA-Z0-9_]{4,20}$/
const REGEX_SMS_CODE = /^\d{4,6}$/

// 验证手机号格式
const validatePhone = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入手机号'))
  } else if (!REGEX_PHONE.test(value) && !REGEX_USERNAME.test(value)) {
    callback(new Error('手机号格式不正确'))
  } else {
    callback()
  }
}

// 验证验证码格式
const validateSmsCode = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入验证码'))
  }
  // else if (!REGEX_SMS_CODE.test(value)) {
  //   callback(new Error('验证码格式不正确'))
  // } 
  // else {
  //   callback()
  // }
}

// 验证密码格式
const validatePassword = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入密码'))
  } else if (value.length < 8 || value.length > 16) {
    callback(new Error('密码长度在8-16位之间'))
  } else {
    callback()
  }
}

// 验证码登录表单验证规则
const smsRules = {
  phone: [
    {
      required: true,
      validator: validatePhone,
      trigger: ['blur', 'input']
    }
  ],
  smsCode: [
    {
      required: true,
      validator: validateSmsCode,
      trigger: ['blur', 'input']
    }
  ]
}

// 密码登录表单验证规则
const passwordRules = {
  phone: [
    {
      required: true,
      message: '请输入手机号/用户名',
      trigger: ['blur', 'input']
    }
  ],
  password: [
    {
      required: true,
      validator: validatePassword,
      trigger: ['blur', 'input']
    }
  ]
}

// 清理表单数据
const clearFormData = () => {
  // 重置表单实例
  if (smsFormRef.value) {
    smsFormRef.value.resetFields()
  }
  if (passwordFormRef.value) {
    passwordFormRef.value.resetFields()
  }

  // 清空表单字段值
  smsForm.phone = ''
  smsForm.smsCode = ''
  passwordForm.phone = ''
  passwordForm.password = ''
  passwordForm.confirmPassword = ''

  // 重置验证状态
  smsFormValid.value = false
  passwordFormValid.value = false
  agreementChecked.value = false // 默认不勾选协议，符合大多数用户习惯

  // 重置loading状态
  loading.value = false
}

// 监听表单输入变化，实时验证 - 合并后的watch监听器
watch([
  () => smsForm.phone,
  () => smsForm.smsCode,
  () => passwordForm.phone,
  () => passwordForm.password,
  () => passwordForm.confirmPassword,
  agreementChecked,
  visible
], ([newSmsPhone, newSmsCode, newPwdPhone, newPassword, newConfirmPassword, newAgreement, newVisible], [oldSmsPhone, oldSmsCode, oldPwdPhone, oldPassword, oldConfirmPassword, oldAgreement, oldVisible]) => {
  // 处理表单输入变化的验证
  if (newSmsPhone !== oldSmsPhone || newSmsCode !== oldSmsCode) {
    validateSmsForm()
  }
  if (newPwdPhone !== oldPwdPhone || newPassword !== oldPassword) {
    validatePasswordForm()
  }

  // 处理协议勾选状态变化
  if (newAgreement !== oldAgreement) {
    validateSmsForm()
    validatePasswordForm()
  }

  // 处理弹窗关闭时清理表单
  if (oldVisible === true && newVisible === false) {
    clearFormData()
  }
})

// 验证验证码表单
const validateSmsForm = () => {
  if (!smsFormRef.value) return

  const phoneValid = REGEX_PHONE.test(smsForm.phone) || REGEX_USERNAME.test(smsForm.phone)
  const codeValid = REGEX_SMS_CODE.test(smsForm.smsCode)
  smsFormValid.value = phoneValid && codeValid && agreementChecked.value
}

// 验证密码表单
const validatePasswordForm = () => {
  if (!passwordFormRef.value) return

  // 对于忘记密码流程，只需要验证密码和确认密码
  const passwordValid = passwordForm.password.length >= 8 && passwordForm.password.length <= 16 && /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/.test(passwordForm.password)
  const confirmValid = passwordForm.password === passwordForm.confirmPassword
  passwordFormValid.value = passwordValid && confirmValid
}

// 监听协议勾选状态变化已合并到上面的复合watch中

// 登录按钮样式类
const smsLoginButtonClass = computed(() => ({
  'login-submit-button': true,
  'login-submit-button-active': smsFormValid.value
}))

const passwordLoginButtonClass = computed(() => ({
  'login-submit-button': true,
  'login-submit-button-active': passwordFormValid.value
}))

// 显示登录弹窗
const showLoginDialog = () => {
  visible.value = true
}

// 隐藏登录弹窗
const hideLoginDialog = () => {
  visible.value = false
  // 清除验证码倒计时
  if (smsCountdown) {
    clearInterval(smsCountdown)
    smsCountdown = null
    smsButtonDisabled.value = false
    smsButtonText.value = '获取验证码'
  }
  // 清理表单数据（通过visible的监听会自动触发清理）
}

// 处理手机号输入
const handlePhoneInput = (value, formType) => {
  const targetForm = formType === 'sms' ? smsForm : passwordForm
  targetForm.phone = value

  // 移除非数字字符（仅对手机号格式）
  if (value && REGEX_PHONE.test(value.substring(0, 2))) {
    const numericValue = value.replace(/\D/g, '')
    targetForm.phone = numericValue
  }
}

// 防抖函数 - 避免频繁点击获取验证码
let lastSmsRequestTime = 0
const SMS_REQUEST_INTERVAL = 1000 // 1秒内防止重复提交

// 获取验证码
const handleGetSmsCode = async () => {
  // 防抖检查
  const now = Date.now()
  if (now - lastSmsRequestTime < SMS_REQUEST_INTERVAL) {
    return
  }
  lastSmsRequestTime = now

  // 验证手机号
  if (!smsForm.phone) {
    ElMessage.error('请输入手机号')
    return
  }

  const phoneValid = REGEX_PHONE.test(smsForm.phone)
  if (!phoneValid) {
    ElMessage.error('手机号格式不正确')
    return
  }

  // 模拟发送验证码
  smsButtonDisabled.value = true
  let countdown = 60
  smsButtonText.value = `${countdown}秒后重新获取`

  if (smsCountdown) {
    clearInterval(smsCountdown)
  }

  smsCountdown = setInterval(() => {
    countdown--
    smsButtonText.value = `${countdown}秒后重新获取`
    if (countdown <= 0) {
      clearInterval(smsCountdown)
      smsButtonDisabled.value = false
      smsButtonText.value = '获取验证码'
    }
  }, 1000)

  // API请求
  try {
    const res = await domesticUserCenter.sendSms({
      phone: smsForm.phone
    })
    console.log('sendSms', res)
    if (res.code == 200) {
      ElMessage.success('验证码发送成功')
    } else {
      ElMessage.error(res.msg || '验证码发送失败')
      // 发送失败时重置按钮状态
      clearInterval(smsCountdown)
      smsButtonDisabled.value = false
      smsButtonText.value = '获取验证码'
    }
  } catch (err) {
    console.error('发送验证码失败:', err)
    ElMessage.error('验证码发送失败，请稍后重试')
    // 发生错误时重置按钮状态
    clearInterval(smsCountdown)
    smsButtonDisabled.value = false
    smsButtonText.value = '获取验证码'
  }
}

// 返回上一步（从设置密码页面返回手机号验证页面）
const goBackToVerify = () => {
  isNext.value = false;
  // 清空密码表单
  passwordForm.password = '';
  passwordForm.confirmPassword = '';
};

// 检查密码强度
const checkPasswordStrength = (password) => {
  if (!password) return 0;
  let strength = 0;

  // 长度检查
  if (password.length >= 10) strength++;

  // 包含数字
  if (/\d/.test(password)) strength++;

  // 包含字母
  if (/[a-zA-Z]/.test(password)) strength++;

  // 包含大小写字母
  if (/[a-z]/.test(password) && /[A-Z]/.test(password)) strength++;

  return strength;
};

// 密码强度显示
const passwordStrength = ref(0);
watch(() => passwordForm.password, (newVal) => {
  passwordStrength.value = checkPasswordStrength(newVal);
});

// 修改密码 提交
const confirmModify = async () => {
  // 验证密码格式
  const passwordValid = passwordForm.password.length >= 8 && passwordForm.password.length <= 16 &&
    /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/.test(passwordForm.password);

  // 验证密码一致性
  const confirmValid = passwordForm.password === passwordForm.confirmPassword;

  if (!passwordValid) {
    ElMessage.error('密码长度需在8-16位之间，且必须同时包含字母和数字');
    return;
  }

  if (!confirmValid) {
    ElMessage.error('两次输入的密码不一致');
    return;
  }

  try {
    loading.value = true;

    // 调用密码重置API
    const res = await domesticUserCenter.createModifyPwd().phone({
      phone: smsForm.phone,
      newPwd: passwordForm.password,
      auth: smsForm.smsCode
    });

    if (res.code === 200) {
      ElMessage({
        type: 'success',
        customClass: 'custom-success-message-icon',
        dangerouslyUseHTMLString: true,
        message: `<img src="${successIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">密码重置成功`,
        offset: 65
      });

      // 延迟关闭弹窗，给用户足够的时间看到成功提示
      setTimeout(() => {
        // 关闭当前弹窗
        visible.value = false;
        // 调用父组件的返回登录方法
        emit('backLogin');

        // 重置表单数据
        clearFormData();
      }, 1500);
    } else {
      ElMessage({
        type: 'error',
        customClass: 'custom-error-message-icon',
        dangerouslyUseHTMLString: true,
        message: `<img src="${errorIcon}" alt="error-icon" style="width: 20px; height: 20px; margin-right: 4px;">${res.msg || '密码重置失败'}`,
        offset: 65
      });
    }
  } catch (err) {
    console.error('密码重置失败:', err);
    ElMessage({
      type: 'error',
      customClass: 'custom-error-message-icon',
      dangerouslyUseHTMLString: true,
      message: `<img src="${errorIcon}" alt="error-icon" style="width: 20px; height: 20px; margin-right: 4px;">${err.message || '密码重置失败，请稍后重试'}`,
      offset: 65
    });
  } finally {
    loading.value = false;
  }
};

// 验证手机号和验证码，进入下一步设置新密码
const handleSmsLogin = async () => {
  if (!smsFormRef.value) return

  // 验证手机号和验证码格式
  const phoneValid = REGEX_PHONE.test(smsForm.phone)
  // const codeValid = REGEX_SMS_CODE.test(smsForm.smsCode)

  if (!phoneValid) {
    ElMessage({
      type: 'error',
      customClass: 'custom-error-message-icon',
      dangerouslyUseHTMLString: true,
      message: `<img src="${errorIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">请输入正确的手机号`,
      offset: 65
    })
    return
  }

  if (!smsForm.smsCode) {
    ElMessage({
      type: 'error',
      customClass: 'custom-error-message-icon',
      dangerouslyUseHTMLString: true,
      message: `<img src="${errorIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">请输入验证码`,
      offset: 65
    })
    return
  }

  try {
    loading.value = true
    // 调用API验证手机号和验证码
    const verifyRes = await domesticUserCenter.verifySendSms({
      phone: smsForm.phone,
      auth: smsForm.smsCode,
      smsType: 'modifyphone'
    })

    if (verifyRes.code === 200) {
      // 验证成功，进入设置新密码页面
      isNext.value = true
      // 将手机号复制到密码表单中
      passwordForm.phone = smsForm.phone
    } else {
      ElMessage.error(verifyRes.msg || '验证码错误，请重新输入')
    }
  } catch (err) {
    console.error('验证失败:', err)
    // ElMessage.error('验证失败，请稍后重试')
  } finally {
    loading.value = false
  }
}

// // 密码登录
// const handlePasswordLogin = async () => {
//   if (!passwordFormRef.value) return
//   if (!agreementChecked.value) {
//     // ElMessage.error('请阅读并同意用户协议')
//     ElMessage({
//       type: 'error',
//       customClass: 'custom-error-message-icon',
//       dangerouslyUseHTMLString: true,
//       message: `<img src="${errorIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">请阅读并同意用户协议`,
//       offset: 65
//     })
//     return
//   }

//   // 验证表单
//   // if (!passwordFormValid.value) {
//   //   ElMessage.error('请填写正确的登录信息')
//   //   return
//   // }

//   try {
//     loading.value = true

//     // 模拟登录请求
//     const loginRes = await domesticUserCenter.createLogin()

//     // 账号密码登录
//     const res = await loginRes.userNameWithPwd({
//       loginMode: "USERNAME",
//       userName: passwordForm.phone,
//       auth: passwordForm.password,
//     })

//     console.log('账号密码登录', res)
//     if (res.code == 200) {
//       const userData = {
//         userInfo: res.data,
//         token: res.data.token,
//         sign: res.data.sign,
//         uid: res.data.uid,
//       }

//       userStore.login(userData)
//       emit('loginSuccess', userData)

//       // 如果用户勾选了记住密码，保存到localStorage
//       if (passwordForm.rememberMe) {
//         // 使用简单的Base64编码存储（注意：这只是基础防护，实际应用可能需要更安全的加密方式）
//         const encodedPhone = btoa(encodeURIComponent(passwordForm.phone))
//         const encodedPassword = btoa(encodeURIComponent(passwordForm.password))
//         localStorage.setItem('rememberedAccount', encodedPhone)
//         localStorage.setItem('rememberedPassword', encodedPassword)
//       } else {
//         // 如果未勾选，清除可能存在的保存信息
//         localStorage.removeItem('rememberedAccount')
//         localStorage.removeItem('rememberedPassword')
//       }

//       hideLoginDialog()
//     } else {
//       ElMessage({
//         type: 'error',
//         customClass: 'custom-error-message-icon',
//         dangerouslyUseHTMLString: true,
//         message: `<img src="${errorIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">${res.msg || '登录失败'}`,
//         offset: 65
//       })
//     }
//   } catch (error) {
//     console.error('登录失败:', error)
//     ElMessage({
//       type: 'error',
//       customClass: 'custom-error-message-icon',
//       dangerouslyUseHTMLString: true,
//       message: `<img src="${errorIcon}" alt="success-icon" style="width: 20px; height: 20px; margin-right: 4px;">${error.message || '登录失败，请稍后重试'}`,
//       offset: 65
//     })
//   } finally {
//     loading.value = false
//   }
// }

// 忘记密码
const handleForgotPassword = () => {
  ElMessage.info('忘记密码功能尚未实现')
}

// 协议点击处理
const handleAgreementClick = (type) => {
  if (type === 'user') { // 用户协议
    var url = 'https://www.ldyuncs.com/ldy/pcpolicy/purchase_policy.html';
  } else if (type === 'privacy') { // 隐私政策
    var url = 'https://www.ldyuncs.com/ldy/pcpolicy/private_policy.html';
  } else if (type === 'platform') { // 平台免责声明
    var url = 'https://www.ldyuncs.com/ldy/pcpolicy/user_policy.html';
  }
  // 发送消息给C#后端
  window.chrome.webview.postMessage({
    action: 'openExternalBrowser',
    url: url
  });
}

// 暴露方法给父组件
defineExpose({
  showLoginDialog,
  hideLoginDialog
})

// 弹窗打开时的处理
const handleOpen = async () => {
  isNext.value = false
  try {
    const loginRes = await domesticUserCenter.createLogin()
    console.log("获取登录方式成功", loginRes);

    // 从localStorage读取保存的账号密码并填充到表单
    const encodedPhone = localStorage.getItem('rememberedAccount')
    const encodedPassword = localStorage.getItem('rememberedPassword')

    if (encodedPhone && encodedPassword) {
      try {
        // 解码并填充表单
        const phone = decodeURIComponent(atob(encodedPhone))
        const password = decodeURIComponent(atob(encodedPassword))

        passwordForm.phone = phone
        passwordForm.password = password
        passwordForm.rememberMe = true

      } catch (decodeError) {
        console.error('解码保存的账号密码失败:', decodeError)
        // 解码失败时清除可能损坏的数据
        localStorage.removeItem('rememberedAccount')
        localStorage.removeItem('rememberedPassword')
      }
    }
  } catch (error) {
    console.error("获取登录方式失败:", error)
  }
}

const backLogin = () => {
  // 调用父组件方法，关闭弹窗
  emit('backLogin')
}
</script>

<style lang="scss" scoped>
.login-dialog-content {
  height: 531px;
  display: flex;
  box-sizing: border-box;

  .scan-login-section {
    background: linear-gradient(90deg, #141414 54.07%, #252525 100%);

    .sub-scan-login-section {
      width: 334px;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: url('@/assets/images/login/login-left-bg.png') no-repeat;
      background-position: left bottom;
      background-size: 100% 40%;

      .scan-qr-code {
        width: 136px;
        height: 136px;
        border-radius: 4px;
        overflow: hidden;

        .qr-code-img {
          width: 100%;
          height: 100%;
          display: block;
        }
      }

      .scan-login-text {
        width: 136px;
        margin-top: 20px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        color: #888;
        border: 1px solid #2a2a26;

        .text-img {
          display: block;
          margin-right: 2px;
        }
      }
    }

  }

  .account-login-section {
    background: #141414;
    width: 100%;

    .sub-account-login-section {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      box-sizing: border-box;
      background: url('@/assets/images/login/login-right-bg.png') no-repeat;
      background-position: center top;
      background-size: 100% 60%;

      .login-tabs {
        width: 332px;
        margin-top: 92px;
        margin-bottom: 25px;
        display: flex;
        align-items: center;
        justify-content: center;

        .login-tabs-title {
          font-size: 18px;
          color: #e2e2e2;
          font-weight: bold;
        }

        :deep(.el-tabs__nav-wrap:after) {
          background-color: transparent !important;
        }

        :deep(.el-tabs__nav) {
          // width: 100% !important;
          margin: 0 auto;
        }

        :deep(.el-tabs__item) {
          // width: 50%;
          color: #e2e2e2;
          font-size: 18px;
          padding: 0 !important;
        }

        :deep(.el-tabs__item.is-active) {
          color: #fff !important;
          font-weight: bold;
        }

        :deep(.el-tabs__active-bar) {
          background-color: transparent;
        }
      }

      .login-form {
        width: 332px;
        flex: 1;

        :deep(.el-input__wrapper) {
          background: transparent !important;
          border-color: #47494A;
        }

        .el-input__suffix {
          color: #999 !important;
        }

        .sms-code-input {}

        .password-tip {
          font-size: 12px;
          color: #999;
        }

        :deep(.el-input-group__append) {
          background-color: transparent !important;
          border: none !important;
          color: #ffe500 !important;
          box-shadow: none !important;
          padding: 0 !important;
          // box-shadow: 0 1px 0 0 var(--el-input-border-color) inset, 0 -1px 0 0 var(--el-input-border-color) inset, -1px 0 0 0 var(--el-input-border-color) inset;
        }

        .get-sms-button {
          padding: 0 10px;
          position: absolute;
          right: 20px;
          // height: 100%;
          // width: 100px;
          // background: transparent !important;
          // border: none !important;
          // color: #ffe500 !important;
          // box-shadow: none !important;
          // padding: 0 !important;
        }

        .login-submit-button {
          width: 100%;
          height: 48px;
          background: #666 !important;
          border-color: #666 !important;
          color: #999 !important;
          font-weight: bold;
          padding: 12px 0;
          cursor: not-allowed;
          border-radius: 4px;
        }

        .login-submit-button-active {
          background: #ffe500 !important;
          border-color: #ffe500 !important;
          color: #121212 !important;
          cursor: pointer;
        }

        .login-submit-button:hover {
          background: #ffe500 !important;
          border-color: #ffe500 !important;
          color: #121212 !important;
        }

        .forgot-password {
          display: flex;
          color: #888 !important;
          justify-content: center;
        }

        .form-actions {
          :deep(.el-form-item__content) {
            display: flex;
            justify-content: space-between !important;
            align-items: center;
          }

          // margin-bottom: 20px;
          // background: red;

          .remember-me {
            color: #888 !important;
          }

          // 输入框选中状态样式
          .el-input__wrapper.is-focused {
            box-shadow: 0 0 0 1px #ff9d00 !important;
            border-color: #ff9d00 !important;
          }

          // 输入框错误状态样式
          .el-form-item.is-error .el-input__wrapper {
            border-color: #ff4949 !important;
          }

          // 自动登录选项样式
          .auto-login {
            // margin-left: 20px;
          }
        }

        // 密码可见性切换图标样式
        .password-toggle-icon {
          color: #999;
          cursor: pointer;
          display: flex;
          align-items: center;
          justify-content: center;
          width: 20px;
          height: 20px;

          &:hover {
            color: #ff9d00;
          }
        }

        /* 密码强度样式 */
        .password-strength {
          display: flex;
          align-items: center;
          margin-bottom: 10px;
          font-size: 12px;
          height: 20px;
        }

        .strength-label {
          margin-right: 10px;
          color: #606266;
        }

        .strength-bars {
          flex: 1;
          height: 6px;
          background-color: #f0f2f5;
          border-radius: 3px;
          overflow: hidden;
          margin-right: 10px;
        }

        .strength-bar {
          height: 100%;
          transition: all 0.3s ease;
          background-color: #f0f2f5;
        }

        .strength-bar.strength-weak {
          background-color: #ff4d4f;
        }

        .strength-bar.strength-medium {
          background-color: #faad14;
        }

        .strength-bar.strength-strong {
          background-color: #52c41a;
        }

        .strength-bar.strength-very-strong {
          background-color: #1890ff;
        }

        .strength-text {
          font-size: 12px;
          margin-left: 10px;
        }

        /* 返回按钮样式 */
        .forgot-password {
          display: flex;
          align-items: center;
          margin-bottom: 10px;
          cursor: pointer;
          margin: 0 auto !important;
        }

        // .forgot-password img {
        //   width: 16px;
        //   height: 16px;
        // }
      }

      .agreement-section {
        font-size: 12px;
        margin-bottom: 30px;

        .agreement-checkbox {
          color: #999 !important;

          .el-checkbox__label {
            color: #999 !important;
          }
        }

        :deep(.el-link__inner) {
          color: #4CE0EB;
        }
      }
    }
  }
}
</style>